//
//  BoatListViewController.m
//  shuiyun
//
//  Created by 徐双 on 2017/9/7.
//  Copyright © 2017年 qianyi. All rights reserved.
//

#import "BoatListViewController.h"
#import "BoatListViewCell.h"

@interface BoatListViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@end

@implementation BoatListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    [self setTitle:@"船方排行"];
    
    [self setUpImageLabel];
    
    [self creatTableview];
}

-(void)setUpImageLabel{

    //中间图片
    
    UIImageView * iconImage1 = [[UIImageView alloc] init];
    [self.view addSubview:iconImage1];
    [iconImage1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.view).with.offset(13);
        //make.left.equalTo(self.view).with.offset(150);
        //make.centerY.equalTo(self.view.mas_centerY);
        make.centerX.equalTo(self.view.mas_centerX);
        make.height.offset(80);
        make.width.offset(80);
    }];
  
    iconImage1.image = [UIImage imageNamed:@"fabu_icon_chuanyuan"];
   
    //中间图片上的数字按钮
    UIImageView * numImage1 = [[UIImageView alloc]init];
    [self.view addSubview:numImage1];
    [numImage1 mas_makeConstraints:^(MASConstraintMaker *make) {
      
        make.centerX.equalTo(iconImage1.mas_centerX);
        make.top.equalTo(iconImage1.mas_bottom).with.offset(-10);
        make.height.offset(25);
        make.width.offset(25);
        
    }];
    numImage1.image = [UIImage imageNamed:@"icon_paiming1"];
    
    //中间图片中文名
    
    UILabel * label1 = [[UILabel alloc] init];
    [self.view addSubview:label1];
    [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(iconImage1.mas_centerX);
        make.top.equalTo(iconImage1.mas_bottom).with.offset(20);
        make.height.offset(30);
        make.width.offset(120);
    }];
    label1.text = @"东方神韵号001";
    label1.textColor = [UIColor colorWithRed:144/225.0 green:144/255.0 blue:144/255.0 alpha:1];
    label1.font = [UIFont systemFontOfSize:17];
    
    //中间图片英文名
    UILabel * label2 = [[UILabel alloc] init];
    [self.view addSubview:label2];
    [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(iconImage1.mas_centerX);
        make.top.equalTo(label1.mas_bottom).with.offset(5);
        make.height.offset(20);
        make.width.offset(60);
    }];
    label2.text = @"Samuel";
    label2.textColor = [UIColor colorWithRed:144/225.0 green:144/255.0 blue:144/255.0 alpha:1];
    label2.font = [UIFont systemFontOfSize:17];
    
    //左边图片
    
    UIImageView * iconImage2 = [[UIImageView alloc] init];
    [self.view addSubview:iconImage2];
    [iconImage2 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.view).with.offset(40);
        make.left.equalTo(self.view).with.offset(30);
        make.height.offset(70);
        make.width.offset(70);
    }];
    
    iconImage2.image = [UIImage imageNamed:@"fabu_icon_chuanyuan"];
    
    //左边图片上的数字按钮
    UIImageView * numImage2 = [[UIImageView alloc]init];
    [self.view addSubview:numImage2];
    [numImage2 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(iconImage2.mas_centerX);
        make.top.equalTo(iconImage2.mas_bottom).with.offset(-10);
        make.height.offset(25);
        make.width.offset(25);
        
    }];
    numImage2.image = [UIImage imageNamed:@"icon_paiming2"];
    
    //左边图片中文名
    
    UILabel * label3 = [[UILabel alloc] init];
    [self.view addSubview:label3];
    [label3 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(iconImage2.mas_centerX);
        //make.left.equalTo(self.view).width.offset(5);
        make.top.equalTo(iconImage2.mas_bottom).with.offset(20);
        make.height.offset(30);
        make.width.offset(120);
    }];
    label3.text = @"东方神韵号001";
    label3.textColor = [UIColor colorWithRed:144/225.0 green:144/255.0 blue:144/255.0 alpha:1];
    label3.font = [UIFont systemFontOfSize:17];
    
    //左边图片英文名
    UILabel * label4 = [[UILabel alloc] init];
    [self.view addSubview:label4];
    [label4 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(iconImage2.mas_centerX);
        make.top.equalTo(label3.mas_bottom).with.offset(5);
        make.height.offset(20);
        make.width.offset(60);
    }];
    label4.text = @"Samuel";
    label4.textColor = [UIColor colorWithRed:144/225.0 green:144/255.0 blue:144/255.0 alpha:1];
    label4.font = [UIFont systemFontOfSize:17];
    
    //右边图片
    
    UIImageView * iconImage3 = [[UIImageView alloc] init];
    [self.view addSubview:iconImage3];
    [iconImage3 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.view).with.offset(40);
        make.right.equalTo(self.view).with.offset(-30);
        make.height.offset(70);
        make.width.offset(70);
    }];
    
    iconImage3.image = [UIImage imageNamed:@"fabu_icon_chuanyuan"];
    
    //右边图片上的数字按钮
    UIImageView * numImage3 = [[UIImageView alloc]init];
    [self.view addSubview:numImage3];
    [numImage3 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(iconImage3.mas_centerX);
        make.top.equalTo(iconImage3.mas_bottom).with.offset(-10);
        make.height.offset(25);
        make.width.offset(25);
        
    }];
    numImage3.image = [UIImage imageNamed:@"icon_paiming3"];
    
    //右边图片中文名
    
    UILabel * label5 = [[UILabel alloc] init];
    [self.view addSubview:label5];
    [label5 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(iconImage3.mas_centerX);
        //make.left.equalTo(self.view).width.offset(5);
        make.top.equalTo(iconImage3.mas_bottom).with.offset(20);
        make.height.offset(30);
        make.width.offset(120);
    }];
    label5.text = @"东方神韵号001";
    label5.textColor = [UIColor colorWithRed:144/225.0 green:144/255.0 blue:144/255.0 alpha:1];
    label5.font = [UIFont systemFontOfSize:17];
    
    //右边图片英文名
    UILabel * label6 = [[UILabel alloc] init];
    [self.view addSubview:label6];
    [label6 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(iconImage3.mas_centerX);
        make.top.equalTo(label5.mas_bottom).with.offset(5);
        make.height.offset(20);
        make.width.offset(60);
    }];
    label6.text = @"Samuel";
    label6.textColor = [UIColor colorWithRed:144/225.0 green:144/255.0 blue:144/255.0 alpha:1];
    label6.font = [UIFont systemFontOfSize:17];
    
    //分割线view
    
    UIView * sepView = [[UIView alloc] init];
    
    [self.view addSubview:sepView];
    
    sepView.backgroundColor = getColor(@"EDEDED");
    [sepView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(label6.mas_bottom).with.offset(25);
        make.left.equalTo(self.view).with.offset(0);
        make.right.equalTo(self.view).with.offset(0);
        make.height.offset(3);
    }];
    
}

-(void)creatTableview{

    //初始化tableView
    
    self.tableView = [[UITableView alloc] init];
    self.tableView.frame = CGRectMake(0, 200 + 25, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT - 64 - 200 - 25);
    
    
    self.tableView.tableFooterView = [[UITableView alloc] initWithFrame:CGRectZero];
    
    self.tableView.backgroundColor = [UIColor whiteColor];
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    //   self.tableView.estimatedRowHeight = 400;
    self.tableView.separatorStyle = UITableViewCellAccessoryNone;//去掉分割线
    
    
    [self.view addSubview:self.tableView];
    
    
    
    [self.tableView registerNib:[UINib nibWithNibName:@"BoatListViewCell" bundle:nil] forCellReuseIdentifier:@"BoatListViewCell"];


}

-(CGFloat )tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    return 100;
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 6;
    
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    BoatListViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"BoatListViewCell"];
    cell.selectionStyle = UITableViewCellEditingStyleNone;
    
    if (indexPath.row == 0) {
        
        cell.indexLabel.text = @"4";
        
        
    }else if (indexPath.row == 1){
        
        cell.indexLabel.text = @"5";
    }else if (indexPath.row == 2){
        
        cell.indexLabel.text = @"6";
    }else if (indexPath.row == 3){
        
        cell.indexLabel.text = @"7";
    }else if (indexPath.row == 4){
        
        cell.indexLabel.text = @"6";
    }else{
        cell.indexLabel.text = @"7";
    }
    

    return cell;
    
}


@end
